package com.qumoyugo.springframework.util;

import cn.hutool.core.util.NumberUtil;

/**
 * @author Cedric
 * @date 2021/12/09 15:05
 * @description 数字工具类示例
 */
public class NumberUtils {

    @SuppressWarnings("unchecked")
    public static <T extends Number> T parseNumber(String source, Class<T> targetType) {
        if (Byte.class == targetType) {
            return (T) Byte.decode(source);
        }
        return (T) NumberUtil.parseNumber(source);
    }
}
